<template>
	<view>
		<block v-if="list.length == 0">
			<view :style="{ height: systemInfo.windowHeight + 'px'}">
				<u-empty src="https://gxmanager.oss-cn-shenzhen.aliyuncs.com/xfqczbgl_static/no-data.png" icon-size="300" text="暂无回访数据，赶紧添加一条吧！"></u-empty>
			</view>
		</block>
		<block v-else>
			<!-- <scroll-view scroll-y>
				<u-table style="overflow-x: auto;">
					<u-tr class="u-tr">
						<u-th class="u-th" width="160rpx">创建人</u-th>
						<u-th class="u-th" width="200rpx">院区</u-th>
						<u-th class="u-th" width="200rpx">实际手术日期</u-th>
						<u-th class="u-th" width="160rpx">投保人</u-th>
						<u-th class="u-th" width="180rpx">被保险人</u-th>
						<u-th class="u-th" width="200rpx">与投保人关系</u-th>
						<u-th class="u-th" width="200rpx">身份证号</u-th>
						<u-th class="u-th" width="200rpx">联系号码</u-th>
						<u-th class="u-th" width="200rpx">手术名称</u-th>
						<u-th class="u-th" width="160rpx">主刀医生</u-th>
						<u-th class="u-th" width="200rpx">客服回访结果</u-th>
						<u-th class="u-th" width="280rpx">院区主管对接结果</u-th>
						<u-th class="u-th" width="280rpx">客服再次回访结果</u-th>
						<u-th class="u-th" width="200rpx">备注</u-th>
					</u-tr>
					<u-tr class="u-tr" v-for="(item,index) in list" :key="index">
						<u-th class="u-th" width="160rpx">{{ item.createByName }}</u-th>
						<u-td class="u-td" width="200rpx">{{ item.deptName || '-' }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.sjSsDate.split(" ")[0] }}</u-td>
						<u-td class="u-td" width="160rpx">{{ item.tbr }}</u-td>
						<u-td class="u-td" width="180rpx">{{ item.bbxr }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.ytbr }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.idCard }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.phone }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.ssName }}</u-td>
						<u-td class="u-td" width="160rpx">{{ item.zdYs }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.kfHfJg }}</u-td>
						<u-td class="u-td" width="280rpx">{{ item.yqZgDjJg }}</u-td>
						<u-td class="u-td" width="280rpx">{{ item.kfZcHfJg }}</u-td>
						<u-td class="u-td" width="200rpx">{{ item.remark }}</u-td>
					</u-tr>
				</u-table>
			</scroll-view> -->
			<!-- 表结构 -->
			<uni-table ref="table" border stripe emptyText="暂无更多数据" style="table-layout: fixed;"><!-- type="selection" -->
				<!-- 表头行 -->
				<uni-tr>
					<uni-th align="center">创建人</uni-th>
					<uni-th align="center">院区</uni-th>
					<uni-th align="center">实际手术日期</uni-th>
					<uni-th align="center">投保人</uni-th>
					<uni-th align="center">被保险人</uni-th>
					<uni-th align="center">与投保人关系</uni-th>
					<uni-th align="center">身份证号</uni-th>
					<uni-th align="center">联系号码</uni-th>
					<uni-th align="center">手术名称</uni-th>
					<uni-th align="center">主刀医生</uni-th>
					<uni-th align="center">客服回访结果</uni-th>
					<uni-th align="center">院区主管对接结果</uni-th>
					<uni-th align="center">客服再次回访结果</uni-th>
					<uni-th align="center">备注</uni-th>
					<uni-th align="center">操作</uni-th>
				</uni-tr>
			
				<!-- 表格数据行 -->
				<uni-tr v-for="(item,index) in list" :key="'tr'+index">
					<uni-td align="center">{{ item.createByName }}</uni-td>
					<uni-td align="center">{{ item.deptName || '-' }}</uni-td>
					<uni-td align="center">{{ item.sjSsDate.split(" ")[0] }}</uni-td>
					<uni-td align="center">{{ item.tbr }}</uni-td>
					<uni-td align="center">{{ item.bbxr }}</uni-td>
					<uni-td align="center">{{ item.ytbr }}</uni-td>
					<uni-td align="center">{{ item.idCard }}</uni-td>
					<uni-td align="center">{{ item.phone }}</uni-td>
					<uni-td align="center">{{ item.ssName }}</uni-td>
					<uni-td align="center">{{ item.zdYs }}</uni-td>
					<uni-td align="center">{{ item.kfHfJg }}</uni-td>
					<uni-td align="center">{{ item.yqZgDjJg }}</uni-td>
					<uni-td align="center">{{ item.kfZcHfJg }}</uni-td>
					<uni-td align="center">{{ item.remark }}</uni-td>
					<uni-td align="center">
						<div style="display: flex;">
							<u-button class="btn action" type="primary" @click="navTo('followUp_upload', { type: 1, id: item.id })">编辑</u-button>
							<u-button class="btn action u-margin-left-5" type="error" @click="delAccount(item.id)">删除</u-button>
						</div>
					</uni-td>
				</uni-tr>
			</uni-table>
			<u-gap height="20"></u-gap>
			<u-loadmore :status="status" />
		</block>
		<u-gap height="200" v-if="list.length != 0"></u-gap>
		<!-- <u-button class="base-add" type="primary" @click="navTo('followUp_upload', { type: 0 })">
			<u-icon class="base-add-icon" name="plus" color="#fff" size="28"></u-icon>新增一条
		</u-button> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 'loadmore',
				list: [],
				page: 1,
				limit: 30,
				total: 0,
				deptId: null,
				dateStar: '',
				dateEnd: '',
				zdYs: '',
				actionShow: false
			};
		},
		onReachBottom() {
			// 判断数据是否全部加载完毕，true则停止请求接口，修改loadingmore状态
			if (this.list.length >= this.total) {
				this.status = 'nomore'
				return;
			}
			this.status = 'loading';
			this.page += 1;
			this.getListData(true); //调用数据
		},
		methods: {
			getListData(isPush = false) {
				this.$api.hfList({
					page: this.page,
					limit: this.limit,
					deptId: this.deptId,
					dateStar: this.dateStar,
					dateEnd: this.dateEnd,
					zdYs: this.zdYs,
				}).then(res => {
					let data = res.data
					this.total = res.count
					if (!isPush) {
						this.list = []
					}
					if (this.total < this.limit) { // 不足10条数据
						this.status = 'nomore'
					}
					for (let i of data) {
						this.list.push(i)
					}
				})
			},
			reset() {
				this.status = 'loading';
				this.page = 1
				this.list = []
				this.getListData()
			},
			navTo(path, params) {
				this.$Router.push({ name: path, params })
			},
			delAccount(id) {
				uni.showModal({
					content: '确定要删除该条数据吗？',
					success: (res) => {
						if (res.confirm) {
							this.$api.yjDel({id}).then(res => {
								this.getListData()
								uni.showToast({
									title: '删除成功！'
								})
							})
						}
					}
				})
			},
		},
		onLoad() {
			const {
				deptId,
				dateStar,
				dateEnd,
				zdYs
			} = this.$Route.query;
			this.deptId = deptId;
			this.dateStar = dateStar;
			this.dateEnd = dateEnd;
			this.zdYs = zdYs;
			this.getListData()
		},
		onNavigationBarButtonTap(e){
			this.actionShow = !this.actionShow;
		},
	}
</script>

<style>
	page {
		background-color: #F7F7F7;
	}
	.u-td {
		height: auto;
	}
	.action {
		padding: 0 10px;
		height: 30px;
		line-height: 30px;
		font-size: 12px;
	}
</style>
